class User < ActiveRecord::Base
  acts_as_authentic
  has_many :user_matches
  
  
  def self.best_players(size=10)
     User.find(:all, :limit=>size, :order=>"points desc, best_time asc", :conditions=>["is_admin=false"])
  end
  def deliver_password_reset_instructions!  
    reset_perishable_token!  
    Notifier.deliver_password_reset_instructions(self)  
  end  
  
  def deliver_verification_instructions
    reset_perishable_token!    
    Notifier.deliver_verification_instructions(self)  
  end
  
  def is_fb_authorized
    return false if self.fb_uid == 0 || !self.fb_at || self.fb_at.empty?    
    return true
  end
  
  def verify!
    self.verified = true
    self.save
  end
end
